using LuckyLang.AST.Expression.ValueTyre;

namespace LuckyLang.AST.Statement;

public class IfBlock : Statement
{
    public Expression.Expression Expr { get; set; }

    public BlockStatement Block { get; set; }

    public IfBlock(Expression.Expression expr,BlockStatement block)
    {
        Block = block;
        Expr  = expr;
    }
    public void Run(ref VariateManager Manager,ref bool isPass)
    {
        if (isPass)
            return;
        var a = Expr.GetValue(ref Manager);
        if (a is BoolValue)
        {
            if ((bool)a.TheValue)
            {
                Manager.Add();
                Block.Run(ref Manager);
                Manager.Remove();
                isPass = true;
            }
        }
    }
}